<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<table class="list" width="100%">
	<tr>
		<th align="center">基础订单号</th>
		<th align="center">寄件姓名</th>
		<th align="center">寄件手机</th>
		<th align="center">生成日期</th>
		<th align="center">网点名称</th>
		<th align="center">寄件地址</th>
		<th align="center">备注</th>
		<th align="center">客服备注</th>
		<th align="center">保存</th>
	</tr>
	<tr>
		<th width="5%" align="left"><s:property value="#request.baseOrderNo" /></th>
		<th width="5%" align="left"><s:property value="#request.baseSenderName" /></th>
		<th width="5%" align="left"><s:property value="#request.baseSenderPhone" /></th>
		<th width="5%" align="left"><s:date name='#request.baseXdDate' format='yyyy-MM-dd HH:mm:ss' /></th>
		<th width="5%" align="left"><s:property value="#request.baseNetsiteName" /></th>
		<th width="11%" align="left"><s:property value="#request.baseFromAddress" /></th>
		<th width="9%" align="left"><input id="baseContent" style="width: 96%" type="text" value=<s:property value="#request.baseContent" />></th>
		<th width="9%" align="left"><input id="edit_<s:property value="#request.baseOrderNo" />" style="width: 96%" type="text" value=<s:property value="#request.serviceNotes" />></th>
		<th width="5%" align="left"><input id="<s:property value="#request.baseOrderNo" />" style="width: 95%" type="button" value="保存" onclick="saveExpressBaseOrder(this)" /></th>
	</tr>
</table>
<br>
<div class="divider"></div>
<table class="list" width="100%" layoutH="138">
	<thead>
		<tr>
			<th align="center">订单号</th>
			<th align="center">收件姓名</th>
			<th align="center">收件人</th>
			<th align="center">收件地址</th>
			<th align="center">订单状态</th>
			<th align="center">订单金额</th>
			<th align="center">已读</th>
			<th align="center">拍摄时间</th>
			<th align="center">图片预览</th>
<!-- 			<th align="center">快递员是否一小时取件</th> -->
			<th align="center">物流状态</th>
			<th align="center">快递单号</th>
			<th align="center">录入单号时间</th>
<!-- 			<th align="center">支付方式</th>
			<th align="center">支付金额</th> -->
			<th align="center">编辑</th>
			<th align="center">保存</th>
			<th align="center">服务扣分</th>
			<th align="center">订单日志</th>
		</tr>
	</thead>
	<tbody>
		<s:iterator var="orders" value="#request.detailOrderList" status="st">
			<tr>
				<th width="5%" align="left"><s:property value="#orders.orderNo" /></th>
				<th width="5%" align="left"><s:property value="#orders.receiverName" /></th>
				<th width="5%" align="left"><s:property value="#orders.receiverTelephone" /></th>
				<th width="10%" align="left"><s:property value="#orders.toProvinceName" /> <s:property value="#orders.toCityName" /> <s:property value="#orders.toDistrictName" /> <s:property value="#orders.toAddress" /></th>
				<th width="8%" align="left"><s:if test="#orders.orderStatus=='NOT_ASSIGNED'">
						<span style="color: blue">等待接单</span>
					</s:if>
					<s:elseif test="#orders.orderStatus=='NETSITE_CANCELLED_NOTINAREA'">
						<span style="color: purple">不在范围</span>
					</s:elseif>
					<s:elseif test="#orders.orderStatus=='NETSITE_CANCELLED_MENDACIOUS'">
						<span style="color: grey">虚假订单</span>
					</s:elseif>
					<s:elseif test="#orders.orderStatus=='ACCEPTED'">
						<span style="color: RosyBrown">等待取件_未打印</span>
					</s:elseif>
					<s:elseif test="#orders.orderStatus=='ACCEPTED_PRINTED'">
						<span style="color: brown">等待取件_已打印</span>
					</s:elseif>
					<s:elseif test="#orders.orderStatus=='PICKED'">
						<span style="color: DarkOrchid">取件成功_未录入</span>
					</s:elseif> <s:elseif test="#orders.orderStatus=='PICKED_INPUT'">
						<span style="color: green">取件成功_已录入</span>
					</s:elseif>
					<s:elseif test="#orders.orderStatus=='CANCELLED'">
						<span style="color: red">订单取消</span>
					</s:elseif></th>
				<th width="5%" align="left"><s:property value="#orders.orderPrice" /></th>
				<th width="8%" align="left"><s:if test="#orders.readFlag==0">
						<span style="color: red">未读</span>
					</s:if>
					<s:elseif test="#orders.readFlag== null">
						<span style="color: red">未读</span>
					</s:elseif>
					<s:elseif test="#orders.readFlag== 1">
						<span style="color: blue">已读</span>
					</s:elseif></th>
				<th width="5%" align="center" ><s:date name='#orders.photoTime' format='yyyy-MM-dd HH:mm:ss' /></th>
				<th width="5%" align="center" >
						<s:if test="#orders.photoUrl==null">
										<span style="color: red">没有图片</span></s:if> 
							<s:elseif test="#orders.photoUrl!=null">
										 <a href="categoryPic_Order?photoUrl=<s:property value="#orders.photoUrl" />"
				target="dialog"  width="1000" height="400" rel="dlg_page10" mask="true" title="图片"><span>预览</span>				
				 </a> </s:elseif>
				
				  </th>
		<%-- 		 <th width="8%" align="left"><s:if test="#orders.oneHourPicked==0">
						<span style="color: red">否</span>
					</s:if>
					<s:elseif test="#orders.oneHourPicked== null">
						<span style="color: red">否</span>
					</s:elseif>
					<s:elseif test="#orders.oneHourPicked== 1">
						<span style="color: blue">是</span>
					</s:elseif></th> --%>
				<th width="8%" align="center">
					<s:if test="#orders.logStatus == null">
						<span style="color: red">没有信息</span>
					</s:if>
					<s:elseif test="#orders.logStatus == 'EMPTY'">
						<span style="color: red">没有信息</span>
					</s:elseif>
					<s:elseif test="#orders.logStatus == 'SEND'">
						<span style="color: green">已发送</span>
					</s:elseif>
					<s:elseif test="#orders.logStatus == 'ARRIVE'">
						<span>到达目标城市</span>
					</s:elseif>
					<s:elseif test="#orders.logStatus == 'SIGN'">
						<span style="color: blue">已收货</span>
					</s:elseif>
				</th>
				<th width="8%" align="left" id="express_<s:property value="#orders.orderNo" />"><s:property value="#orders.expressOrderNo" /></th>
				<th width="8%" align="left" id="express_<s:property value="#orders.inputNoTime" />"><s:date name='#orders.inputNoTime' format='yyyy-MM-dd HH:mm:ss' /></th>
<%-- 				<th width="5%" align="center"><s:if test="#orders.payingStyle==null">
										<span style="color: red">没有支付</span></s:if> 
									<s:elseif test="#orders.payingStyle==1">
										<span >微信支付</span></s:elseif>
									<s:elseif test="#orders.payingStyle==0">
										<span >现金支付</span></s:elseif></th>
				<th width="5%" align="center" ><s:property value='#orders.paymentAmount' /></th> --%>
				<th width="8%" align="center">
				<input id="edit_<s:property value="#orders.orderNo" />" style="width: 96%" type="text" placeHolder="输入快递单号">
				
				<input type="hidden" id="old_logExcompany" value="<s:property value="#orders.logisticsCompanyId" />">
				<select name="logExcompany" id="select_logExcompany" style="width: 193px">
									<option value="10" <s:if test="#orders.logisticsCompanyId==10">selected="selected"</s:if>>韵达快递</option>
									<option value="11" <s:if test="#orders.logisticsCompanyId==11">selected="selected"</s:if>>中通快递</option>
									<option value="12" <s:if test="#orders.logisticsCompanyId==12">selected="selected"</s:if>>圆通快递</option>
									<option value="13" <s:if test="#orders.logisticsCompanyId==13">selected="selected"</s:if>>申通快递</option>
									<option value="14" <s:if test="#orders.logisticsCompanyId==14">selected="selected"</s:if>>顺丰快递</option>
				</select>
				</th>
				<th width="4%" align="center"><input id="orderNo_<s:property value="#orders.orderNo" />" style="width: 95%" type="button" value="保存" onclick="saveExpressOrder(this)" /></th>
			
				<th width="5%" align="center"><a href="getOrderServiceByOrderNoAction?orderNo=<s:property value="#orders.orderNo" />&courierId=<s:property value="#orders.courierId" />" target="dialog" width="685" height="500" mask=true rel="orderService"><span>服务</span> </a></th>
				<th width="5%" align="center"><a href="getOrderDealLogByOrderNoAction?orderNo=<s:property value="#orders.orderNo" />" target="dialog" width="685" height="600" mask=true rel="orderLog"><span>日志</span> </a></th>
			</tr>
		</s:iterator>
	</tbody>
</table>



<script type="text/javascript">

//绑定快递单号
function saveExpressOrder(obj){
	var orderNo = $(obj).attr("id").substr(8);  //截取到该小订单的订单号
	var express_no = $("#edit_"+orderNo).val();  //拿到编辑框的值
	var logExcompany=$('#select_logExcompany option:selected') .val();
	var old_logExcompany=$("#old_logExcompany").val();
	alert(logExcompany);
	alert(old_logExcompany);
	var changeExcompanyFlag=0;
	var content="确认";
	if(logExcompany==old_logExcompany)
	{
		if(express_no==""){
			alertMsg.warn("请输入快递单号！");
			return;
		}
		content="把快递单号修改为:"+express_no;
	}else{
		changeExcompanyFlag=1;
		content=content+"更换快递公司。"
	}
	alertMsg.confirm(content, {
		okCall: function(){
			$.ajax({
                type: 'post',
                url:'<%=basePath%>editOrderByExpressNo',
				data : {
					orderNo : orderNo,
					express_no : express_no,
					changeExcompanyFlag : changeExcompanyFlag,
					logExcompany:logExcompany
				},
				success : function(data) {
					if (data == 'true') {
						if(express_no!=""){
							$("#express_" + orderNo).text(express_no); //修改页面上的值为快递单号
						}
						//$(obj).attr("disabled", "true"); //禁用当前按钮
						alertMsg.correct("修改成功！");
					} else {
						alertMsg.error("修改失败！");
					}
				}
				});
			}
		});
	}
	
	
//添加客服备注
function saveExpressBaseOrder(obj){
	var baseNo=obj.id;
	var notes = $("#edit_"+baseNo).val();  //拿到编辑框的值
	var baseContent = $("#baseContent").val(); 
	if(notes==""&&baseContent==""){
		alertMsg.warn("请输入备注！");
		return;
	}
	alertMsg.confirm("确认修改备注？", {
		okCall: function(){
			$.ajax({
                type: 'post',
                url:'<%=basePath%>editBaseOrderNotes',
				data : {
					baseNo : baseNo,
					serviceNotes : notes,
					baseContent :baseContent
				},
				success : function(data) {
					if (data == 'true') {
						alertMsg.correct("添加备注成功！");
					} else {
						alertMsg.error("添加备注失败！");
					}
				}
				});
			}
		});
	}
</script>
